﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Management.Instrumentation;
using System.IO;

namespace Ada
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServerManagerHost" in both code and config file together.
    public class ServerManagerHost : Ada.Protocol.IServerManager
    {

        public bool AddServer(string hostName, int port, int connectionCount, bool requiresLogin, string username, string password, bool SSL, bool needsGroup)
        {
            throw new NotImplementedException();
        }

        public bool AddDownload(Stream nzbFile, string title)
        {
            try
            {
                Ada.ServiceConatainer.Instance.newsgroupService.EnqueueNZB(nzbFile, title);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public Protocol.DownloadInformation GetDownloadInformation(string downloadName)
        {
            throw new NotImplementedException();
            //return new Protocol.DownloadInformation("Test", MainClass.srvManager.TotalMB.ToString(), MainClass.srvManager.Speed.ToString(), "Tom");
        }

        public Protocol.ServerInformation GetServerInformation()
        {
            System.Net.NetworkInformation.IPGlobalProperties properties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
            System.IO.DriveInfo downloadDriveInfo = new System.IO.DriveInfo(System.IO.Path.GetPathRoot(Config.Instance.DownloadPath));

            return new Protocol.ServerInformation(Environment.MachineName, Environment.OSVersion.ToString(), downloadDriveInfo.TotalSize, downloadDriveInfo.AvailableFreeSpace);
        }


        public bool AddDownload(string nzbFile)
        {
            throw new NotImplementedException();
        }

        public List<Protocol.DownloadInformation> GetDownloads()
        {
            throw new NotImplementedException();
        }
    }
}
